<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>商家详情</title>
		<link rel="stylesheet" href="__AGENT__/css/css.css" />
		<style type="text/css">
			#sfz_pic{position: relative;}/*opacity: 0;*/
			.upload,.upload1{position: absolute;top: 0;left: 0;width: 100%;height: 100%;opacity: 0;}
		</style> 
	</head>

	<body>
		 <form class="mui-input-group gerenzl_group layui-form">
			<div class="layui-form-item">
    			<div class="renz_img " id="yyzz_pic" style="margin-left: 120px; margin-top: 20px;">
    				<input type="hidden" name="logo" id="thumb_1"  value="{$data.logo}" lay-verify="required" autocomplete="off" class="layui-input"/>
    				<input type="file" id="upload_1" class="upload1" style="width: 50%;height: 30%;" value="选择图片文件" multiple/>
    				{if condition="$data.logo == null"}
						<span><img class='img_1' id='img_1' id='img_1' style="width: 150px;height: 150px;" src="__LOGO__/1/logo.png"></span>
					{else /}
						<span><img class='img_1' id='img_1' src="{$data.logo}" style="width: 150px;height: 150px;"></span>
					{/if}
    			</div>
			</div> 
			<div class="layui-form-item">
				<label class="layui-form-label">名称</label>
				<div class="layui-input-block update_shurk">
					<input style="width: 350px; type="text" name="project_name"  value="{$data.project_name}" lay-verify="required" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item">
				<label class="layui-form-label">地址</label>
				<div class="layui-input-block update_shurk">
					<input style="width: 350px;" type="text" name="addres" value="{$data.addres}" lay-verify="required" placeholder="联系地址" autocomplete="off" class="layui-input">
				</div>
			</div>
			<div class="layui-form-item update_btnbox">
				<div class="layui-input-block">
					<button class="layui-btn" type="button" lay-submit lay-filter="submit_from">立即提交</button>
					<button type="reset" class="layui-btn layui-btn-primary">重置</button>
				</div>
			</div>
		</form>
	</body>
</html>
<script type="text/javascript" src="__PUBLIC__/static/js/jquery.min.js"></script>
<link rel="stylesheet" href="__PUBLIC__/static/layui/css/layui.css">
<script src="__PUBLIC__/static/layui/layui.all.js"></script>
<script>
	//图片上传
	layui.use(['form','upload'], function(){
  		var $ = layui.jquery,upload = layui.upload,form = layui.form;
  		
  		var uploadInst_1 = upload.render({
			elem: '#upload_1'
		    ,auto: false //选择文件后不自动上传
		    ,choose: function(obj){
			    //将每次选择的文件追加到文件队列
			    var files = obj.pushFile();
			    //预读本地文件，如果是多文件，则会遍历。(不支持ie8/9)
			    obj.preview(function(index, file, result){
			    	$('#img_1').attr('src', result); //图片链接（base64）
			    	var sendData = result.substring(result.indexOf(";base64,")+8);
			    	$.post("{:url('oem/index/upload')}",{value:sendData},function(data){ 
	                            if(data.code == '200'){  
	                            	$('#thumb_1').val(data.url);
	                            }else{  
	                                layer.msg(data.msg);
	                            }  
                    		});
			    });
			}
		    ,url: "{:url('oem/index/upload')}"
		    ,accept:'images'
		});
		//监听表单提交
		form.on('submit(submit_from)', function(data){
			tijiao();
  			return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
		});
		
		
	});
	//提交表单
	function tijiao(){
  		 $.ajax({
             	type:"post",
                url:"{:url('index/show_agent')}",
                data: $('.layui-form').serialize(),//表单数据
                success:function(data){
                    if(data.code==200){
                    	layer.msg('成功', {
						  icon: 1,
						  time: 1500 //2秒关闭（如果不配置，默认是3秒）
						}, function(){
							window.parent.location.reload();
							var index = parent.layer.getFrameIndex(window.name); //获取窗口索引  
					       	parent.layer.close(index); 
						});
                    }else{
                    	layer.msg('失败！');//保存成功提示
                    }
                },error:function(data){
                	var a = data;
                }
        });
  		
  	}
</script>